script_enemy_main{

let xpos=0;
let ypos=0;
let repeat=40;

let shot1=0;
let bullet1=[];
let timer1=[];
let shot2=0;
let bullet2=[];
let timer2=[];
let fall2=[];

let character="KurumiHotaru";
let cutin=character;
let dispelled=0;
let spellcards=1;
if(GetCommonData("Difficulty")>=3){ spellcards=2; }
let damagerate=10;
let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let frame=0; let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshotb6=("\script\SoundEffects\shotb6.wav");
let SEfireworks3=("\script\SoundEffects\fireworks3.wav");
let SEfireworks5=("\script\SoundEffects\fireworks5.wav");

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsHotaru1.txt");

	LoadGraphic("\script\Images\CharacterSprites\Kurumi.png");
	LoadGraphic("\script\Images\CharacterSprites\Hotaru.png");

	LoadSE("\script\SoundEffects\shotb6.wav");
	LoadSE("\script\SoundEffects\fireworks3.wav");
	LoadSE("\script\SoundEffects\fireworks5.wav");

	SetLife(180);
	SetTimer(30);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(false);
	MagicCircle(false);
	SetX(cx);
	SetY(miny-1000);
	
	SetCommonData("UseSpell1",0);
	SetCommonData("UseSpell2",0);
}
	
@MainLoop{
SetCollisionA(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionA(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetCollisionB(GetCommonData("Boss1X"),GetCommonData("Boss1Y"),16);
SetCollisionB(GetCommonData("Boss2X"),GetCommonData("Boss2Y"),16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=3; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();


if(time==0){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Kurumi-Hotaru - Nonspell 3 - Kurumi.txt",GetCommonData("Boss1X"),GetCommonData("Boss1Y"),0,0,0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Kurumi-Hotaru - Nonspell 3 - Hotaru.txt",GetCommonData("Boss2X"),GetCommonData("Boss2Y"),0,0,0);
}

let boss1x=GetCommonData("Boss1X");
let boss1y=GetCommonData("Boss1Y");
let boss2x=GetCommonData("Boss2X");
let boss2y=GetCommonData("Boss2Y");


if(GetCommonData("Difficulty")==1){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(4){
		SetShotDirectionType(PLAYER);
		if(time%200==0){ CreateShot01(boss1x+10,boss1y-35,speed,angle,191,0);
		SetCommonData("UseSpell1",20);
		}
		if(time%200!=0){ CreateShot01(boss2x+10,boss2y-45,speed,angle,191,0);
		SetCommonData("UseSpell2",20);
		}
		SetShotDirectionType(ABSOLUTE);
		speed-=0.5;
		}
	angle+=360/12;
	}
PlaySE(SEshotb6);
}

if((time+80)%300==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx-rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}
if((time+230)%300==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx+rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}

if((time+145)%150==0 && time>=60){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,xpos,maxy-10);
	Obj_SetAngle(shot1,270+rand(-5,5));
	Obj_SetSpeed(shot1,8.5);
	ObjShot_SetGraphic(shot1,97);
	ObjShot_SetBombResist(shot1,true);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
PlaySE(SEfireworks5);
}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){ bullet1=erase(bullet1,i); timer1=erase(timer1,i); i--; }
	else{
	Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])-0.1);

	if(timer1[i]%5==0 && timer1[i]>=5){
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(-0.1,-1.5),rand(-0.5,-2.5),0.01,0.01,-0.1,2,28,0);
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(0.1,1.5),rand(-0.5,-2.5),-0.01,0.01,0.1,2,28,0);
	}

	if(timer1[i]==repeat){
	let shot1=0;
	let shot2=1;
	let shot3=2;
	let shot4=3;
	let color=rand_int(37,46);
	let angle1=rand(0,360);
		loop(5){
		let delay1=rand_int(5,20);
		CreateShotA(shot1,Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),0);
		SetShotDataA(shot1,0,rand(2.5,4),angle1,0,-0.05,0,color+24);
			loop(8){
			let delay2=rand_int(15,50);
			CreateShotA(shot2,0,0,0);
			SetShotDataA(shot2,0,rand(2.5,4.5),rand(0,360),0,-0.03,0,color+12);
			SetShotKillTime(shot2,delay2);
				loop(8){
				CreateShotA(shot3,0,0,0);
				SetShotDataA(shot3,0,rand(1,2),rand(0,360),0,-0.03,0,color);
				SetShotKillTime(shot3,rand_int(20,40));
				AddShot(delay2-1,shot2,shot3,0);
				}
			AddShot(delay1-1,shot1,shot2,0);
			}
		SetShotKillTime(shot1,delay1);
		FireShot(shot1);
		angle1+=360/20;
		}
	repeat++;
	}
	if(repeat==43){ Obj_Delete(bullet1[i]); repeat=40; PlaySE(SEfireworks3); }

	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Easy

//=============================================================================================================

if(GetCommonData("Difficulty")==2){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(4){
		SetShotDirectionType(PLAYER);
		if(time%200==0){ CreateShot01(boss1x+10,boss1y-35,speed,angle,191,0);
		SetCommonData("UseSpell1",20);
		}
		if(time%200!=0){ CreateShot01(boss2x+10,boss2y-45,speed,angle,191,0);
		SetCommonData("UseSpell2",20);
		}
		SetShotDirectionType(ABSOLUTE);
		speed-=0.5;
		}
	angle+=360/12;
	}
PlaySE(SEshotb6);
}

if((time+80)%300==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx-rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}
if((time+230)%300==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx+rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}

if((time+145)%150==0 && time>=60){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,xpos,maxy-10);
	Obj_SetAngle(shot1,270+rand(-5,5));
	Obj_SetSpeed(shot1,8.5);
	ObjShot_SetGraphic(shot1,97);
	ObjShot_SetBombResist(shot1,true);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
PlaySE(SEfireworks5);
}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){ bullet1=erase(bullet1,i); timer1=erase(timer1,i); i--; }
	else{
	Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])-0.1);

	if(timer1[i]%3==0 && timer1[i]>=5){
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(-0.1,-1.5),rand(-0.5,-2.5),0.01,0.01,-0.1,2,28,0);
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(0.1,1.5),rand(-0.5,-2.5),-0.01,0.01,0.1,2,28,0);
	}

	if(timer1[i]==repeat){
	let shot1=0;
	let shot2=1;
	let shot3=2;
	let shot4=3;
	let color=rand_int(37,46);
	let angle1=rand(0,360);
		loop(5){
		let delay1=rand_int(5,20);
		CreateShotA(shot1,Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),0);
		SetShotDataA(shot1,0,rand(2.5,4.5),angle1,0,-0.05,0,color+24);
			loop(8){
			let delay2=rand_int(15,50);
			CreateShotA(shot2,0,0,0);
			SetShotDataA(shot2,0,rand(3,5),rand(0,360),0,-0.03,0,color+12);
			SetShotKillTime(shot2,delay2);
				loop(8){
				CreateShotA(shot3,0,0,0);
				SetShotDataA(shot3,0,rand(1,2),rand(0,360),0,-0.03,0,color);
				SetShotKillTime(shot3,rand_int(20,40));
				AddShot(delay2-1,shot2,shot3,0);
				}
			AddShot(delay1-1,shot1,shot2,0);
			}
		SetShotKillTime(shot1,delay1);
		FireShot(shot1);
		angle1+=360/20;
		}
	repeat++;
	}
	if(repeat==43){ Obj_Delete(bullet1[i]); repeat=40; PlaySE(SEfireworks3); }

	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Normal

//=============================================================================================================

if(GetCommonData("Difficulty")==3){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(6){
		SetShotDirectionType(PLAYER);
		if(time%200==0){ CreateShot01(boss1x+10,boss1y-35,speed,angle,191,0);
		SetCommonData("UseSpell1",20);
		}
		if(time%200!=0){ CreateShot01(boss2x+10,boss2y-45,speed,angle,191,0);
		SetCommonData("UseSpell2",20);
		}
		SetShotDirectionType(ABSOLUTE);
		speed-=0.4;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if((time+50)%250==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx-rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}
if((time+175)%250==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx+rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}

if((time+90)%125==0 && time>=60){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,xpos,maxy-10);
	Obj_SetAngle(shot1,270+rand(-5,5));
	Obj_SetSpeed(shot1,8.5);
	ObjShot_SetGraphic(shot1,97);
	ObjShot_SetBombResist(shot1,true);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
PlaySE(SEfireworks5);
}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){ bullet1=erase(bullet1,i); timer1=erase(timer1,i); i--; }
	else{
	Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])-0.1);

	if(timer1[i]%2==0 && timer1[i]>=5){
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(-0.1,-1.5),rand(-0.5,-2.5),0.01,0.01,-0.1,2,28,0);
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(0.1,1.5),rand(-0.5,-2.5),-0.01,0.01,0.1,2,28,0);
	}

	if(timer1[i]==repeat){
	let shot1=0;
	let shot2=1;
	let shot3=2;
	let shot4=3;
	let color=rand_int(37,46);
	let angle1=rand(0,360);
		loop(5){
		let delay1=rand_int(5,20);
		CreateShotA(shot1,Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),0);
		SetShotDataA(shot1,0,rand(2.5,4.5),angle1,0,-0.05,0,color+24);
			loop(12){
			let delay2=rand_int(15,50);
			CreateShotA(shot2,0,0,0);
			SetShotDataA(shot2,0,rand(3,5),rand(0,360),0,-0.03,0,color+12);
			SetShotKillTime(shot2,delay2);
				loop(12){
				CreateShotA(shot3,0,0,0);
				SetShotDataA(shot3,0,rand(1,2),rand(0,360),0,-0.03,0,color);
				SetShotKillTime(shot3,rand_int(25,50));
				AddShot(delay2-1,shot2,shot3,0);
				}
			AddShot(delay1-1,shot1,shot2,0);
			}
		SetShotKillTime(shot1,delay1);
		FireShot(shot1);
		angle1+=360/20;
		}
	repeat++;
	}
	if(repeat==43){ Obj_Delete(bullet1[i]); repeat=40; PlaySE(SEfireworks3); }

	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Hard

//=============================================================================================================

if(GetCommonData("Difficulty")==4){

if(time%100==0 && time>=60 && GetTimer>0){
let angle=0;
	loop(12){
	let speed=3;
		loop(8){
		SetShotDirectionType(PLAYER);
		if(time%200==0){ CreateShot01(boss1x+10,boss1y-35,speed,angle,191,0);
		SetCommonData("UseSpell1",20);
		}
		if(time%200!=0){ CreateShot01(boss2x+10,boss2y-45,speed,angle,191,0);
		SetCommonData("UseSpell2",20);
		}
		SetShotDirectionType(ABSOLUTE);
		speed-=0.3;
		}
	angle+=360/12;
	}
usespell=20;
PlaySE(SEshotb6);
}

if((time+50)%220==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx-rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}
if((time+160)%220==0 && time>=60 && GetTimer>0){
SetCommonData("WarningSide",3); //1-top 2-left 3-bottom 4-right
SetCommonData("WarningX",cx+rand(40,120));
SetCommonData("WarningTime",90);
SetCommonData("WarningSize",0.75);
SetCommonData("WarningType",1);
CreateEnemyFromFile("script\Functions\warnings.txt",0,0,0,0,0);
xpos=GetCommonData("WarningX");
}

if((time+75)%110==0 && time>=60){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,xpos,maxy-10);
	Obj_SetAngle(shot1,270+rand(-5,5));
	Obj_SetSpeed(shot1,8.5);
	ObjShot_SetGraphic(shot1,97);
	ObjShot_SetBombResist(shot1,true);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
PlaySE(SEfireworks5);
}

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){ bullet1=erase(bullet1,i); timer1=erase(timer1,i); i--; }
	else{
	Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])-0.1);

	if(timer1[i]%2==0 && timer1[i]>=5){
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(-0.1,-1.5),rand(-0.5,-2.5),0.01,0.01,-0.1,2,28,0);
	CreateShot12(Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),rand(0.1,1.5),rand(-0.5,-2.5),-0.01,0.01,0.1,2,28,0);
	}

	if(timer1[i]==repeat){
	let shot1=0;
	let shot2=1;
	let shot3=2;
	let shot4=3;
	let color=rand_int(37,46);
	let angle1=rand(0,360);
		loop(5){
		let delay1=rand_int(5,20);
		CreateShotA(shot1,Obj_GetX(bullet1[i]),Obj_GetY(bullet1[i]),0);
		SetShotDataA(shot1,0,rand(2.5,4.5),angle1,0,-0.05,0,color+24);
			loop(10){
			let delay2=rand_int(15,50);
			CreateShotA(shot2,0,0,0);
			SetShotDataA(shot2,0,rand(3,5),rand(0,360),0,-0.03,0,color+12);
			SetShotKillTime(shot2,delay2);
				loop(10){
				CreateShotA(shot3,0,0,0);
				SetShotDataA(shot3,0,rand(1,2.5),rand(0,360),0,-0.03,0,color);
				SetShotKillTime(shot3,rand_int(30,60));
				AddShot(delay2-1,shot2,shot3,0);
				}
			AddShot(delay1-1,shot1,shot2,0);
			}
		SetShotKillTime(shot1,delay1);
		FireShot(shot1);
		angle1+=360/20;
		}
	repeat++;
	}
	if(repeat==43){ Obj_Delete(bullet1[i]); repeat=40; PlaySE(SEfireworks3); }

	timer1[i]=timer1[i]+1;
	}
i++;
}

} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }

#include_function "script/Functions/HealthBar.txt";
}

@BackGround{
}

@DrawLoop{
}

@Finalize{
//	SetCommonData("Conversation",1);
}

}